package com.yanqu.road.server.cmd.activity.hongxian;

import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.pb.activity.HongXianActivityProto;
import com.yanqu.road.server.cmd.base.AbstractCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.gameplayer.GamePlayer;
import com.yanqu.road.server.manger.activity.ActivityMgr;
import com.yanqu.road.server.manger.activity.hongxian.HongXianActivityMgr;
import com.yanqu.road.server.protocol.GameErrorCode;
import com.yanqu.road.server.protocol.Protocol;

@Cmd(code = Protocol.S_HONG_XIAN_NOTICE, desc = "获取公告")
public class HongXianNoticeCmd extends AbstractCommand {

    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {
        return true;
    }

    @Override
    public void execute(GamePlayer player, YanQuMessage packet) throws Exception {
        // 没有活动
        if (!ActivityMgr.activityInShowTime(HongXianActivityMgr.getActivityInfo()) || HongXianActivityMgr.getConfig() == null) {
            ret = GameErrorCode.E_ACTIVITY_OVER_TIME;
            return;
        }

        player.sendPacket(Protocol.C_HONG_XIAN_NOTICE, HongXianActivityProto.CrossHongXianNoticeReqMsg.newBuilder().setActivityId(HongXianActivityMgr.getActivityId()));

    }

    @Override
    public void sendData(GamePlayer player) {
        if(ret != 0){
            player.sendPacket(Protocol.U_HONG_XIAN_NOTICE, HongXianActivityProto.HongXianNoticeRespMsg.newBuilder().setRet(ret));
        }
    }
}
